using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Data.SqlClient;

/// <summary>
/// Summary description for CartItemDAO
/// </summary>
public class CartItemDAO : SQLDBHelper
{
    private const string SQL_SELECT_ALL = "SELECT TOP 4 * FROM CartItem";

	public CartItemDAO()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public IList<CartItem> GetAll()
    {
        IList<CartItem> list = new List<CartItem>();

        Connect();

        SqlCommand cmd = new SqlCommand(SQL_SELECT_ALL, conn);
        SqlDataReader dr = cmd.ExecuteReader();

        CartItem itm;

        while (dr.Read())
        {
            itm = new CartItem();
            itm.ItemID = dr.GetInt32(0);
            itm.ItemName = dr.GetString(1);
            itm.Price = dr.GetDouble(2);            
            itm.Detail = dr.GetString(3);
            itm.Quantity = dr.GetInt32(4);
            itm.Amount = dr.GetDouble(5);
            itm.ImageUrl = dr.GetString(6);
            list.Add(itm);
        }

        Disconnect();

        return list;
    }

}
